<%- include('../../public/header.html')%>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/2.2.1/jquery.min.js"></script>
<script type="text/javascript" src="/admin/js/jqPaginator.js"></script>
<div><a href="/admin/article/add">增加内容</a></div>
<table>
    <thead>
        <tr>
            <td>内容标题</td>
            <td>所属分类</td>
            <td>作者</td>
            <td>封面</td>
            <td>排序</td>
            <td>状态</td>
            <td>操作</td>
        </tr>
    </thead>
    <tbody>
        <%for(var i = 0;i<list.length;i++){%>
        <tr>
            <td><%=list[i].title%></td>
            <td><%=list[i].cate[0].title%></td>
            <td><%=list[i].author%></td>
            <td><img style="width: 25px;height: 25px;" src="<%=list[i].article_img%>" alt=""></td>
            <td><%=list[i].sort%></td>
            <td align="center">
                <%if(list[i].status==1){%>
                    <img src="/admin/image/yes.gif" class="chstatus">

                    <%}else{%>
                    <img src="/admin/image/no.gif" class="chstatus"/>
                    <%}%>
            </td>
            <td>
                <a href="/admin/article/edit?id=<%=list[i]._id%>"  alt="">修改</a>
                <a href="/admin/article/delete?id=<%=list[i]._id%>" class="delete" alt="">删除</a>
            </td>
        </tr>
        <%}%>
    </tbody>
</table>
<div class="pagination" id="pagination">
<script>
        $('#pagination').jqPaginator({
        totalPages: <%=totalPages%>,
        visiblePages: 5,
        currentPage: <%=currentPage%>,
        onPageChange: function (num, type) {
            if(type=="change"){
                location.href="/admin/article?page="+num;
            }
        //     console.log(type);    
        //    console.log('当前第' + num + '页')
        }
    })
</script>
    
</body>
</html>